package com.renwei.yunlong.activity.me;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.renwei.yunlong.R;
import com.renwei.yunlong.base.BaseActivity;
import com.renwei.yunlong.global.IntentKey;
import com.renwei.yunlong.utils.CommonUtils;
import com.zyf.fwms.commonlibrary.utils.StatusBarUtil;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 办公电话页面
 * <p>
 * Created by Administrator on 2017/8/23.
 */

public class OfficePhoneActivity extends BaseActivity implements View.OnClickListener {

    @Bind(R.id.iv_back)
    ImageView ivBack;
    @Bind(R.id.tv_title)
    TextView tvTitle;
    @Bind(R.id.tv_edit)
    TextView tvEdit;
    @Bind(R.id.et_phone)
    EditText etPhone;

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_user_certificate_name);
        ButterKnife.bind(this);
        StatusBarUtil.setColor(this, CommonUtils.getColor(this, R.color.title_color), 0);
        initData();
    }

    private void initData() {
        tvTitle.setText("办公电话");
        tvEdit.setVisibility(View.VISIBLE);
        tvEdit.setText("保存");
        ivBack.setVisibility(View.VISIBLE);
        ivBack.setOnClickListener(this);
        tvEdit.setOnClickListener(this);
        String phone = String.valueOf(getIntent().getStringExtra(IntentKey.OFFICE_PHONE));
        etPhone.setText(phone);
        etPhone.setSelection(etPhone.getText().toString().length());
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.tv_edit:
                String phone = etPhone.getText().toString().trim();
                setResult(IntentKey.OFFICE_PHONE_KEY, new Intent().putExtra(IntentKey.OFFICE_PHONE, phone));
                finish();
                break;
            default:
                break;
        }
    }
}
